home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
protocols
/
advice.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
6KB
|
198 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from __future__ import generators
from new import instancemethod
from types import ClassType, FunctionType, InstanceType
import sys
__all__ = [
'metamethod',
'supermeta',
'getMRO',
'classicMRO',
'mkRef',
'StrongRef',
'addClassAdvisor',
'isClassAdvisor',
'add_assignment_advisor',
'determineMetaclass',
'getFrameInfo',
'minimalBases']
from peak.util import decorators
def addClassAdvisor(callback, depth = 2, frame = None):
warn = warn
import warnings
warn(addClassAdvisor.__doc__, DeprecationWarning, 2)
if not depth:
pass
return decorators.decorate_class(callback, 0 + 1, frame)
def add_assignment_advisor(callback, depth = 2, frame = None):
warn = warn
import warnings
warn(add_assignment_advisor.__doc__, DeprecationWarning, 2)
if not depth:
pass
return decorators.decorate_assignment(callback, 0 + 1, frame)
def getFrameInfo(frame):
warn = warn
import warnings
warn(getFrameInfo.__doc__, DeprecationWarning, 2)
return decorators.frameinfo(frame)
def determineMetaclass(bases, explicit_mc = None):
warn = warn
import warnings
warn(determineMetaclass.__doc__, DeprecationWarning, 2)
return decorators.metaclass_for_bases(bases, explicit_mc)
def isClassAdvisor(ob):
warn = warn
import warnings
warn(isClassAdvisor.__doc__, DeprecationWarning, 2)
return decorators.metaclass_is_decorator(ob)
def metamethod(func):
return (property,)((lambda ob: func.__get__(ob, ob.__class__)))
try:
from ExtensionClass import ExtensionClass
except ImportError:
ClassicTypes = ClassType
ClassicTypes = (ClassType, ExtensionClass)
def classicMRO(ob, extendedClassic = False):
stack = []
push = stack.insert
pop = stack.pop
push(0, ob)
while stack:
cls = pop()
yield cls
p = len(stack)
for b in cls.__bases__:
push(p, b)
if extendedClassic:
yield InstanceType
yield object
def getMRO(ob, extendedClassic = False):
if isinstance(ob, ClassicTypes):
return classicMRO(ob, extendedClassic)
elif isinstance(ob, type):
return ob.__mro__
return (ob,)
try:
from _speedups import metamethod, getMRO, classicMRO
except ImportError:
pass
def supermeta(typ, ob):
starttype = type(ob)
mro = starttype.__mro__
if typ not in mro:
starttype = ob
mro = starttype.__mro__
mro = iter(mro)
for cls in mro:
if cls is typ:
mro = [ cls.__dict__ for cls in mro ]
break
continue
[]
else:
raise TypeError('Not sub/supertypes:', starttype, typ)
typ = type(ob)
class theSuper([], 'theSuper', (object,)):
def __getattribute__(self, name):
for d in mro:
if name in d:
descr = d[name]
try:
descr = descr.__get__
except AttributeError:
return descr
return descr(ob, typ)
continue
return object.__getattribute__(self, name)
return theSuper()
def minimalBases(classes):
warn = warn
import warnings
warn('protocols.advice.minimalBases is deprecated; please do not use it', DeprecationWarning, 2)
classes = _[1]
candidates = []
for m in classes:
for n in classes:
if issubclass(n, m) and m is not n:
break
continue
[]
elif m in candidates:
candidates.remove(m)
candidates.append(m)
return candidates
from weakref import ref
class StrongRef(object):
__slots__ = 'referent'
def __init__(self, referent):
self.referent = referent
def __call__(self):
return self.referent
def __hash__(self):
return hash(self.referent)
def __eq__(self, other):
return self.referent == other
def __repr__(self):
return 'StrongRef(%r)' % self.referent
def mkRef(ob, *args):
try:
return ref(ob, *args)
except TypeError:
return StrongRef(ob)